import axios from 'axios';

//分页列表接口
const URI_DATAGRID = "/#{lowermodule}/api/#{lowername}/datagrid";
//删除
const URI_REMOVE = "/#{lowermodule}/api/#{lowername}/remove";
//ADD提交
const URI_ADD_SUBMIT = "/#{lowermodule}/api/#{lowername}/add";
//UPDATE提交
const URI_UPDATE_SUBMIT = "/#{lowermodule}/api/#{lowername}/update";

export const datagrid = function(params, callback = function(res) {}) {
	axios.post(URI_DATAGRID, params).then((response) => {
		callback(response.data);
	});
}

export const remove = function(params, callback = function(res) {}) {
	axios.post(URI_REMOVE, params).then((response) => {
		callback(response.data);
	});
}

export const add = function(params, callback = function(res) {}) {
	axios.post(URI_ADD_SUBMIT, params).then((response) => {
		callback(response.data);
	});
}

export const update = function(params, callback = function(res) {}) {
	axios.post(URI_UPDATE_SUBMIT, params).then((response) => {
		callback(response.data);
	});
}

export default {
	datagrid,
	add,
	update,
	remove
}